package client.object;

import java.rmi.RemoteException;

import javax.vecmath.Quat4d;
import javax.vecmath.Vector3d;

import client.rmiManager.RMIManager;

import server.object.CObject3D;

public class CObject3DClientImpl implements CObject3DClient {

	private String name;
	
	private CObject3D object;
	private PObject3D presentation;
	
	public CObject3DClientImpl(String name) {

		this.name = name;
		
		object = RMIManager.rmiManagerInstance().getCObject3D(name); 
		presentation = new PObject3DImpl(this);

		try {
			System.out.println(object.getName());
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	@Override
	public void updateTransform(Vector3d position, Quat4d orientation, String geometry) {
		presentation.updateTransform();
		System.out.println("J'ai changé!!!!!!" + position + " - " + orientation);
	}

	@Override
	public void setCObject(CObject3D object) {
		this.object = object;
	}

	@Override
	public CObject3D getCObject() {
		return object;
	}
	
	@Override
	public PObject3D getPresentation() {
		return presentation;
	}

	@Override
	public String getGeometry() {
		try {
			return object.getGeometry();
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public String getName() {
		try {
			return object.getGeometry();
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public Quat4d getOrientation() {
		try {
			return object.getOrientation();
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public Vector3d getPosition() {
		try {
			return object.getPosition();
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public void move(Vector3d vector) {
		try {
			object.move(vector);
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
}
